const express = require('express')

const app = express()

app.get('/server', (request, response) => {
  // 设置响应头  设置允许跨域
  response.setHeader('Access-Control-Allow-Origin', '*')

  // 设置响应体
  response.send('HELLO EXPRESS GET')
})

app.all('/server', (request, response) => {
  // 设置响应头  设置允许跨域
  response.setHeader('Access-Control-Allow-Origin', '*')

  response.setHeader('Access-Control-Allow-Header', '*')
  // 设置响应体
  setTimeout(() => {
    response.send('HELLO EXPRESS POST')
  },3000)
})

app.listen(8000, () => {
  console.log('服务启动，8000 监听中....')
})
